package com.netease.examination.service.buyer;

import com.netease.examination.dao.buyer.BuyerDAO;
import com.netease.examination.dto.BuyerGoods;
import com.netease.examination.model.Goods;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * designed by destiny
 *
 * @author destiny
 *         e-mail destinywk@163.com
 *         github https://github.com/DestinyWang
 *         oschina https://git.oschina.net/destinywk
 * @version JDK 1.8.0_101
 * @since 2017/3/30 22:16
 */
@Service
public class BuyerService {

    @Resource
    private BuyerDAO buyerDAO;

    public List<Goods> findGoodsList(){
        return buyerDAO.findGoodsList();
    }

    public List<Goods> findUnbuyGoodsList(){
        return buyerDAO.findUnbuyGoodsList();
    }

    public Goods findGoodsDetail(Long goodId){
        return buyerDAO.findGoodsDetail(goodId);
    }

    public void putIntoShoppingCar(BuyerGoods goods){
        buyerDAO.putIntoShoppingCar(goods);
    }

    public List<BuyerGoods> findShoppingCar(){
        return buyerDAO.findShoppingCar();
    }

    @Transactional
    public void settleAccounts(){
        buyerDAO.setGoodsTag();
        buyerDAO.settleAccounts();
        buyerDAO.emptyShoppingCar();
    }

    public void exitShoppingCar(){
        buyerDAO.emptyShoppingCar();
    }

    public List<BuyerGoods> findHistoryOrder(){
        return buyerDAO.findHistoryOrder();
    }

}
